﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

namespace TextTools
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            OpenFileDialog openF = new OpenFileDialog();
            openF.Filter = "Text Files (*.txt)|*.txt*";
            openF.ShowDialog();
            toolStripStatusLabel2.Text = openF.FileName;

            AddToTextBox();
        }

        private void menuItem5_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void AddToTextBox()
        {
            removeSpacesTxt.Text = File.ReadAllText(toolStripStatusLabel2.Text);
            oneWordTxt.Text = File.ReadAllText(toolStripStatusLabel2.Text);
            charRemoveTxt.Text = File.ReadAllText(toolStripStatusLabel2.Text);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            string final;
            final = removeSpacesTxt.Text;
            final = Regex.Replace(final, @"\s", "");
            removeSpacesTxt.Text = final;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveF = new SaveFileDialog();
            saveF.Filter = "Text File (*.txt)|*.txt*";
            saveF.DefaultExt = ".txt";
            saveF.ShowDialog();
            File.WriteAllText(saveF.FileName, removeSpacesTxt.Text);
            Process.Start(saveF.FileName);
        }

        private void button5_Click(object sender, EventArgs e)
        {
            LargerPreview lrg = new LargerPreview();
            lrg.textBox1.Text = removeSpacesTxt.Text;
            lrg.ShowDialog();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            string final;
            final = oneWordTxt.Text;
            string[] finalSplit;
            finalSplit = final.Split(' ');
            oneWordTxt.Text = String.Join(Environment.NewLine, finalSplit);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveF = new SaveFileDialog();
            saveF.Filter = "Text File (*.txt)|*.txt*";
            saveF.DefaultExt = ".txt";
            saveF.ShowDialog();
            File.WriteAllText(saveF.FileName, oneWordTxt.Text);
            Process.Start(saveF.FileName);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            LargerPreview lrg = new LargerPreview();
            lrg.textBox1.Text = oneWordTxt.Text;
            lrg.ShowDialog();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            string final;
            final = charRemoveTxt.Text;
            final = final.Replace(charToRemove.Text, string.Empty);
            charRemoveTxt.Text = final;
        }

        private void button9_Click(object sender, EventArgs e)
        {
            LargerPreview lrg = new LargerPreview();
            lrg.textBox1.Text = charRemoveTxt.Text;
            lrg.ShowDialog();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveF = new SaveFileDialog();
            saveF.Filter = "Text File (*.txt)|*.txt*";
            saveF.DefaultExt = ".txt";
            saveF.ShowDialog();
            File.WriteAllText(saveF.FileName, charRemoveTxt.Text);
            Process.Start(saveF.FileName);
        }

        private void menuItem7_Click(object sender, EventArgs e)
        {
            About abt = new About();
            abt.ShowDialog();
        }
    }
}
